Fixed bitfield check in User::loadFromId()
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 10 Jul 2015 23:52:26 +0000 (16:52 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 10 Jul 2015 23:52:28 +0000 (16:52 -0700)
* READ_LOCKING is a composite field, so it can yeild 00, 01,
  10, or 11 for the relevant two bits. Only one of them should
  pass the check to avoid locking and snapshot breaking queries
  for no reason.

Change-Id: Ief04ac20c7639fcf79443a3ee39a471542a59551

includes/User.php

index 63c0d37..26d54ab 100644 (file)
@@ -387,7 +387,8 @@ class User implements IDBAccessObject {
 
                // Try cache (unless this needs to lock the DB).
                // NOTE: if this thread called saveSettings(), the cache was cleared.
-               if ( ( $flags & self::READ_LOCKING ) || !$this->loadFromCache() ) {
+               $locking = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING );
+               if ( $locking || !$this->loadFromCache() ) {
                        wfDebug( "User: cache miss for user {$this->mId}\n" );
                        // Load from DB (make sure this thread sees its own changes)
                        if ( wfGetLB()->hasOrMadeRecentMasterChanges() ) {